package com.ruoyi.web.controller.spoken;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.SpokenHome;
import com.ruoyi.system.service.ISpokenHomeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value = "/home", description = "首页模块")
@RequestMapping("/spoken/home")
@RestController
public class HomeController extends BaseController {

    @Autowired
    ISpokenHomeService homeService;

    @ApiOperation("新建模块内容")
    @PostMapping
    public AjaxResult add(@RequestBody SpokenHome home){
        return toAjax(homeService.insert(home));
    }

    @ApiOperation("修改模块内容")
    @PutMapping
    public AjaxResult edit(@RequestBody SpokenHome home){
        return toAjax(homeService.update(home));
    }

    @ApiOperation("根据模块ID查询模块内容")
    @GetMapping("/{homeId}")
    public AjaxResult getByType(@PathVariable Long homeId){
        SpokenHome home = homeService.getById(homeId);
        return AjaxResult.success(home);
    }

    @ApiOperation("查询所有模块内容")
    @GetMapping("/list")
    public AjaxResult list(SpokenHome home){
        return success(homeService.selectList(home));
    }
}
